package com.jack.student;

import java.util.Scanner;

public class ChangeInfo {
    public static void alterName(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要修改的学生学号:");
        long stuID = scanner.nextLong();
        for (StudentInfo lis: AddInfo.students) {
            if(lis.getStuId() == stuID){
                System.out.println("请输入你要修改的名字:");
                lis.setStuName(scanner.next());
                System.out.println("修改成功!");
                break;
            }else if(lis.getStuId() == AddInfo.students.get(AddInfo.students.size()-1).getStuId()){
                System.out.println("你输入的学号不存在,请从新输入:");
            }
        }
    }


    public static void alterAge(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要修改的学生学号:");
        long stuID = scanner.nextLong();
        for (StudentInfo lis: AddInfo.students) {
            if(lis.getStuId() == stuID){
                System.out.println("请输入你要修改的年龄:");
                lis.setAge(scanner.nextInt());
                System.out.println("修改成功!");
                break;
            }else if(lis.getStuId() == AddInfo.students.get(AddInfo.students.size()-1).getStuId()){
                System.out.println("你输入的学号不存在,请从新输入:");
            }
        }
    }

    public static void alterPhoneNum(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要修改的学生学号:");
        long stuID = scanner.nextLong();
        for (StudentInfo lis: AddInfo.students) {
            if(lis.getStuId() == stuID){
                System.out.println("请输入你要修改的电话:");
                lis.setIphoneNum(scanner.next());
                System.out.println("修改成功!");
                break;
            }else if(lis.getStuId() == AddInfo.students.get(AddInfo.students.size()-1).getStuId()){
                System.out.println("你输入的学号不存在,请从新输入:");
            }
        }
    }

    public static void alterClassRoom(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要修改的学生学号:");
        long stuID = scanner.nextLong();
        for (StudentInfo lis: AddInfo.students) {
            if(lis.getStuId() == stuID){
                System.out.println("请输入你要修改的班级:");
                lis.setClassRoom(scanner.next());
                System.out.println("修改成功!");
                break;
            }else if(lis.getStuId() == AddInfo.students.get(AddInfo.students.size()-1).getStuId()){
                System.out.println("你输入的学号不存在,请从新输入:");
            }
        }
    }
}
